[id].vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 导航栏 -->
  5. <HomePageNavigation1></HomePageNavigation1>
  6. <!-- 列表页广告一 -->
  7. <HomeTopTen :imgurl="adList[0]" v-if="adList[0]"></HomeTopTen>
  8. <!-- 面包屑导航 -->
  9. <div class="breadcrumb">
  10. <div class="inner">
  11. <span class="location">当前位置:</span>
  12. <el-breadcrumb :separator-icon="ArrowRight">
  13. <el-breadcrumb-item>
  14. <NuxtLink to="/">首页</NuxtLink>
  15. </el-breadcrumb-item>
  16. <el-breadcrumb-item >
  17. <NuxtLink :to="{ path: `/newsList/${routLevelId}` }">
  18. {{ routLevelTitle }}
  19. </NuxtLink>
  20. </el-breadcrumb-item>
  21. <el-breadcrumb-item>{{ routeNewsTtitle }}</el-breadcrumb-item>
  22. </el-breadcrumb>
  23. </div>
  24. </div>
  25. <!-- 资讯列表 -->
  26. <div class="newsDetail">
  27. <div class="inner">
  28. <div class="innerLeft">
  29. <div class="LeftTop">
  30. <h1>{{ newsDetail.title }}</h1>
  31. <p>
  32. 来源: <span>{{ newsDetail.copyfrom }}</span>
  33. 作者: <span>{{ newsDetail.author }}</span>
  34. 发布时间: <span>{{ time }}</span>
  35. </p>
  36. <!-- <img :src="newsDetail.imgurl" v-if="newsDetail.imgurl&&newsDetail.level==2||newsDetail.level==3"> -->
  37. </div>
  38. <div class="leftBottom" v-html="newsDetail.content" v-if="newsDetail.content"></div>
  39. <!-- 免责声明: -->
  40. <div class="disclaimer" v-if="newsDetail.copyfrom!='本网'">
  41. <p>原文链接:{{ newsDetail.fromurl }}</p>
  42. <p>[免责声明]本文来源于网络转载,仅供学习交流使用,不构成商业目的。 版权归原作者所有,如涉及作品内容,版权和其他问题,请在30日与本网联系,我们将第一时间处理。</p>
  43. </div>
  44. </div>
  45. <div class="innerRight">
  46. <!-- 热点资讯1 -->
  47. <div class="hotList1">
  48. <DetailHotNews></DetailHotNews>
  49. </div>
  50. <!-- 热点资讯2 -->
  51. <div class="hotList2">
  52. <DetailHotNews2></DetailHotNews2>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. <!-- 页面底部 -->
  58. <HomeFoot1></HomeFoot1>
  59. </template>
  60. <script setup>
  61. //1.页面依赖 start ---------------------------------------->
  62. import { onMounted } from 'vue'
  63. import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
  64. import { ArrowRight } from '@element-plus/icons-vue'
  65. const nuxtApp = useNuxtApp();
  66. const axios = nuxtApp.$axios;
  67. //获得跳转过来的id
  68. const route = useRoute();
  69. const articleId = route.params.id; //获得该页面的id
  70. //1.页面依赖 end ---------------------------------------->
  71. //2.页面数据 start ---------------------------------------->
  72. //2.1 资讯详情
  73. const newsDetail = ref({})
  74. const routeNewsTtitle = ref("");
  75. //2.2 发布日期
  76. const time = ref("");
  77. //2.3 路径
  78. const routLevelTitle = ref("");
  79. const routLevelId = ref("");
  80. //2.4获取详情
  81. async function getPageData() {
  82. const mkdata = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  83. method: 'GET',
  84. query: {
  85. 'articleid': articleId
  86. },
  87. });
  88. //获取内容
  89. newsDetail.value = mkdata.data;
  90. //获取路径
  91. routLevelTitle.value = newsDetail.value.cat_name;
  92. routLevelId.value = newsDetail.value.category_id;
  93. //获取发布时间
  94. time.value = newsDetail.value.updated_at.split(' ')[0];
  95. //修正标题长度
  96. if (newsDetail.value.title.length >= 30) {
  97. routeNewsTtitle.value = newsDetail.value.title.substr(0, 30) + "...";
  98. } else {
  99. routeNewsTtitle.value = newsDetail.value.title
  100. }
  101. }
  102. getPageData();
  103. //2.5 获得广告
  104. //广告列表
  105. let adList = ref([]);
  106. async function getAdData(){
  107. const adData = await requestDataPromise('/web/getWebsiteAdvertisement',{method:'GET',query:{'ad_tag':'DETAIL'}});
  108. adList.value = adData.data;
  109. }
  110. getAdData();
  111. //2.页面数据 end ---------------------------------------->
  112. //3.设置seo信息 start---------------------------------------->
  113. //3.1 设置seo信息
  114. const setData = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  115. method: 'GET',
  116. query: {
  117. 'articleid': articleId
  118. },
  119. });
  120. let seoTitle = setData.data.title + "_三农资讯网_全国政务信息一体化应用平台";
  121. let seoDescription = setData.data.introduce + "_三农资讯网_全国政务信息一体化应用平台";
  122. let seoKeywords = setData.data.keyword + "_三农资讯网_全国政务信息一体化应用平台";
  123. useSeoMeta({
  124. title: seoTitle,
  125. meta: [
  126. { name: 'description', content: seoDescription },
  127. { name: 'keywords', content: seoKeywords }
  128. ]
  129. });
  130. //4.设置seo信息 end---------------------------------------->
  131. </script>
  132. <style lang="less" scoped>
  133. @import url('@/assets/css/detail.less');
  134. </style>